﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
    <!-- Copied from Microsoft Expression Blend 4 -->
    <SolidColorBrush x:Key="ScrollBarBackgroundBrush" Color="#FF3D3D3D" />
    <SolidColorBrush x:Key="ScrollBarForegroundBrush" Color="#FF333333" />
    <SolidColorBrush x:Key="ScrollBarButtonBrush" Color="#FF808080"/>
    <SolidColorBrush x:Key="ScrollBarHoverBrush" Color="#FFCCCCCC"/>
    <SolidColorBrush x:Key="ScrollBarPressedBrush" Color="#FFE5E5E5"/>
    <SolidColorBrush x:Key="ScrollBarDisabledBrush" Color="#FF5C5C5C" />
    
    <Style TargetType="{x:Type RepeatButton}">
        <Setter Property="Focusable" Value="false" />
        <Setter Property="Foreground" Value="{StaticResource ScrollBarButtonBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Name="Border" Background="Transparent">
                        <ContentPresenter Name="ContentPresenter" HorizontalAlignment="Center" VerticalAlignment="Center" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Value="{StaticResource ScrollBarHoverBrush}" Property="Foreground" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Value="{StaticResource ScrollBarPressedBrush}" Property="Foreground" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">
        <Setter Property="Foreground" Value="{StaticResource ScrollBarForegroundBrush}" />
        <Setter Property="Background" Value="{StaticResource ScrollBarBackgroundBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollBar}">
                    <Grid Name="GridRoot" Background="{TemplateBinding Background}">
                        <Grid.RowDefinitions>
                            <RowDefinition MaxHeight="18" />
                            <RowDefinition Height="0.00001*" />
                            <RowDefinition MaxHeight="18" />
                        </Grid.RowDefinitions>
                        <RepeatButton Name="DecreaseRepeat" Command="{x:Static ScrollBar.LineUpCommand}" Margin="0,0,0,1">
                            <Path Name="DecreaseArrow" Data="F0 M 0,7 L 3.5,0 7,7 Z" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="{Binding ElementName=DecreaseRepeat, Path=Foreground}" />
                        </RepeatButton>
                        <Track Name="PART_Track" Grid.Row="1" IsDirectionReversed="true" Focusable="false">
                            <Track.Thumb>
                                <Thumb Name="Thumb" Background="{StaticResource ScrollBarButtonBrush}">
                                    <Thumb.Style>
                                        <Style TargetType="{x:Type Thumb}">
                                            <Setter Property="Template">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType="{x:Type Thumb}">
                                                        <Grid Name="Grid">
                                                            <Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Fill="Transparent" />
                                                            <Rectangle Name="Rectangle1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="7" Height="Auto" RadiusX="4" RadiusY="4" Fill="{TemplateBinding Background}" />
                                                        </Grid>
                                                        <ControlTemplate.Triggers>
                                                            <Trigger Property="Tag" Value="Horizontal">
                                                                <Setter TargetName="Rectangle1" Property="Width" Value="Auto" />
                                                                <Setter TargetName="Rectangle1" Property="Height" Value="7" />
                                                            </Trigger>
                                                        </ControlTemplate.Triggers>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>
                                    </Thumb.Style>
                                </Thumb>
                            </Track.Thumb>
                            <Track.IncreaseRepeatButton>
                                <RepeatButton Name="PageUp" Command="{x:Static ScrollBar.PageDownCommand}" Opacity="0" Focusable="false" />
                            </Track.IncreaseRepeatButton>
                            <Track.DecreaseRepeatButton>
                                <RepeatButton Name="PageDown" Command="{x:Static ScrollBar.PageUpCommand}" Opacity="0" Focusable="false" />
                            </Track.DecreaseRepeatButton>
                        </Track>
                        <RepeatButton Name="IncreaseRepeat" Grid.Row="2" Command="{x:Static ScrollBar.LineDownCommand}" Margin="0,1,0,0">
                            <Path Name="IncreaseArrow" Data="F0 M 0,0 L 3.5,7 7,0 Z" HorizontalAlignment="Center" VerticalAlignment="Center" Fill="{Binding ElementName=IncreaseRepeat, Path=Foreground}" />
                        </RepeatButton>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger SourceName="Thumb" Property="IsMouseOver" Value="true">
                            <Setter Value="{StaticResource ScrollBarHoverBrush}" TargetName="Thumb" Property="Background" />
                        </Trigger>
                        <Trigger SourceName="Thumb" Property="IsDragging" Value="true">
                            <Setter Value="{StaticResource ScrollBarPressedBrush}" TargetName="Thumb" Property="Background" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Value="{StaticResource ScrollBarDisabledBrush}" TargetName="IncreaseArrow" Property="Fill" />
                            <Setter Value="{StaticResource ScrollBarDisabledBrush}" TargetName="DecreaseArrow" Property="Fill" />
                            <Setter TargetName="Thumb" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="Orientation" Value="Horizontal">
                            <Setter TargetName="GridRoot" Property="LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="-90" />
                                </Setter.Value>
                            </Setter>
                            <Setter TargetName="PART_Track" Property="LayoutTransform">
                                <Setter.Value>
                                    <RotateTransform Angle="-90" />
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Width" Value="Auto" />
                            <Setter Property="Height" Value="17" />
                            <Setter TargetName="Thumb" Property="Tag" Value="Horizontal" />
                            <Setter TargetName="DecreaseRepeat" Property="Command" Value="{x:Static ScrollBar.LineLeftCommand}" />
                            <Setter TargetName="IncreaseRepeat" Property="Command" Value="{x:Static ScrollBar.LineRightCommand}" />
                            <Setter TargetName="PageDown" Property="Command" Value="{x:Static ScrollBar.PageLeftCommand}" />
                            <Setter TargetName="PageUp" Property="Command" Value="{x:Static ScrollBar.PageRightCommand}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>